package com.leemz.spring.converter;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * 实现BeanPostProcessor接口，实现方法来对注入的bean进行加工
 * @author leemz
 */
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if(bean instanceof Category) {
            Category category = (Category)bean;
            category.setAddress("北京市大兴区");
        }
        return bean;
    }
}
